package tt.com.bodybeautymanager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import tt.com.bodybeautymanager.mapper.DeadCosmeticMapper;
import tt.com.bodybeautymanager.mapper.DeadCosmeticStaffMapper;
import tt.com.bodybeautymanager.service.DeadCosmeticAddService;
import tt.com.business.mapper.DeadCosmeticMappers;
import tt.com.common.enums.Status;
import tt.com.common.model.DeadCosmetic;
import tt.com.common.model.DeadCosmeticStaff;
import tt.com.common.util.CommonResult;

import java.util.Date;

@Service
public class AddServiceImpl extends ServiceImpl<DeadCosmeticStaffMapper, DeadCosmeticStaff> implements DeadCosmeticAddService {
    @Override
    public CommonResult addService(DeadCosmeticStaff deadCosmeticStaff, String createUserId,String staffid) {
        QueryWrapper<DeadCosmeticStaff> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne("data_status",0);
        //设置整容师员工id
        deadCosmeticStaff.setStaffId(staffid);
        //设置创建时间
        deadCosmeticStaff.setCreateTime(new Date());
        //设置创建人的id
        deadCosmeticStaff.setCreateUserId(createUserId);
        int result = baseMapper.insert(deadCosmeticStaff);
        if (baseMapper.selectOne(queryWrapper)!=null){
            return CommonResult.buildR(Status.SYSTEM_ERROR, "不允许重复添加");
        }else if (result>1) {
            return CommonResult.buildR(Status.OK, "添加成功");
        } else {
            return CommonResult.buildR(Status.SYSTEM_ERROR, "添加失败");
        }

    }
}
